<template>
	<view class="listOfMines u-skeleton">
		<u-navbar title="新增地图" :background="{
			'backgroundColor':'#fff'
		}" :borderBottom="false" class="u-skeleton-rect"></u-navbar>
		<view class="top u-skeleton-rect" v-if="info">
			<view class="item">
				<image class="iil-img" :src="$util.img('/static/img/card/PNG2.png')" mode="widthFix"></image>
				<view class="txt">{{info.balance}}</view>
			</view>
			<view class="item">
				<image class="iil-img" :src="$util.img('/static/img/card/金币.png')" mode="widthFix"></image>
				<view class="txt">{{info.giveaway}}</view>
			</view>
			<view class="item">
				<image class="iil-img" :src="$util.img('/static/img/card/宝石.png')" mode="widthFix"></image>
				<view class="txt">{{info.bs_num}}</view>
			</view>
		</view>
		<view class="title u-skeleton-rect">水晶矿藏</view>
		<block v-if="info">
			<view class="li-item u-skeleton-rect" v-for="(item,index) in info.list" :key="index" :style="{
				'background-image':'url(' + $util.img(item.image) + ')'}">
				<view class="left">
					<view class="li-title">
						<text style="margin-right: 20rpx;">{{item.name}}</text>
					</view>
					<view class="li-title">
						<text>需要卡片：{{item.card_num}}</text>
					</view>
					<view class="li-tips">{{item.cycle}}天最多可挖</view>
					<view class="li-num">
						<image class="iil-img" :src="$util.img('/static/img/card/宝石.png')" mode="widthFix"></image>
						{{item.output}}
					</view>
				</view>
				<view class="right">
					<view class="xh">消耗</view>
					<view class="xh">
						<image class="iil-img" :src="$util.img('/static/img/card/宝石.png')" mode="widthFix"></image>
						{{item.consume}}
					</view>
					<view class="btn" @click="btn(item.id)">开启地图</view>
				</view>
			</view>
		</block>

		<u-skeleton :loading="loding" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				loding: true, //初始化骨架屏展示
				info: null,
				isJudge: false
			}
		},
		onShow() {
			this.setConfig();
		},
		methods: {
			//获取玩法攻略
			//或许页面大致数据
			async setConfig() {
				let res = await this.$http.sendrequest({
					url: '/goods/mineSpaceList'
				});
				this.info = res.data;
				this.loding = false; //初始化骨架屏展示
			},
			// 开启矿坑
			btn(id) {
				if (this.isJudge) {
					return false;
				}
				this.isJudge = true;
				setTimeout(() => {
					this.isJudge = false
				}, 2000)
				this.$http.asyncSendrequest({
					url: '/profile/openMineSpace',
					data: {
						id
					},
					success: res => {
						this.isJudge = false;
						this.$util.taost({
							title: res.msg,
							callback: v => {
								if (res.code == '0') {
									this.setConfig();
								}
							}
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.listOfMines {
		width: 100%;
		height: 100vh;

		.top {
			display: flex;
			align-items: center;
			// justify-content: space-between;
			margin: 30rpx;
			padding: 10rpx 0;
			.item {
				display: flex;
				align-items: center;
				width: 200rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				margin-right: 20rpx;
				.txt {
					font-size: 26rpx;
					width: calc(100% - 40rpx);
				}

				image {
					width: 40rpx;
					margin-right: 10rpx;
				}
			}
		}

		.title {
			font-size: 28rpx;
			font-weight: bold;
			margin: 20rpx 30rpx;

		}

		.li-item {
			margin: 0 30rpx 30rpx;
			min-height: 200rpx;
			background: #fff;
			border-radius: 20rpx;
			background-size: 100% 100%;
			background-repeat: no-repeat;
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				.li-title {
					font-size: 28rpx;
					color: #fff;
					font-size: 30rpx;
					font-weight: bold;
					margin-bottom: 26rpx;
					display: flex;
					align-items: center;
					image{
						width: 30rpx;
						height: 30rpx;
						margin: 0 20rpx;
					}
				}

				.li-tips {
					color: #fff;
					margin-bottom: 10rpx;
					font-size: 24rpx;
				}

				.li-num {
					color: #fff;
					font-size: 24rpx;
					display: flex;
					align-items: center;

					image {
						width: 30rpx;
						margin-right: 10rpx;
					}
				}
			}

			.right {
				width: 260rpx;
				height: 180rpx;
				background: #fff;
				border-radius: 20rpx;
				padding: 20rpx;

				.xh {
					font-size: 24rpx;
					display: flex;
					align-items: center;
					margin-bottom: 10rpx;
					justify-content: right;

					image {
						width: 30rpx;
						margin:0 10rpx;
					}
				}

				.btn {
					width: 160rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 24rpx;
					color: #fff;
					background: #303133;
					padding: 10rpx 20rpx;
					margin-top: 20rpx;
					border-radius: 6rpx;
					margin-left: 30rpx;
				}
			}
		}
	}
</style>